<template>
  <!-- 底部部分 -->
  <footer class="footer">
    <span class="todo-count">
      剩余
      <strong>{{list.length}}</strong>
    </span>
    <ul class="filters" @click="$emit('dataDisplay',type)">
      <li>
        <a :class="{selected:type==='all'}" @click="type='all'" href="#/all">全部</a>
      </li>
      <li>
        <a :class="{selected:type==='active'}" href="#/active" @click="type='active'">进行中</a>
      </li>
      <li>
        <a :class="{selected:type==='completed'}" href="#/completed" @click="type='completed'">已完成</a>
      </li>
    </ul>
    <button v-if="showList" @click="$emit('clearItem')" class="clear-completed">清除已完成</button>
  </footer>
</template>

<script>
export default {
  data() {
    return {
      type: "all"
    };
  },
  props: {
    list: {
      requied: true,
      type: Array
    }
  },
  computed: {
    showList() {
      return this.list.some(item => item.isDone);
    }
  }
};
</script>

<style>
</style>